package org.fei.demo.mq;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import org.fei.demo.model.MqMsg;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

public class RabbitMQReceiver {

    @RabbitListener(queues = "q.BOOT.RABBIT.TEST", containerFactory = "basicRabbitListenerContainerFactory")
    public void getMsg(Message message, Channel channel){
        try {
            MqMsg mqMsg = JSON.parseObject(message.getBody(), MqMsg.class);
            System.out.println("接收到消息：" + mqMsg);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
